package iscript.gameFramework.GameLite.system.util
{
	
	public class StringHelper
	{
		
		static public function isWhitespace(char:String):Boolean
		{
			if (char.length == 0) return true;
			switch (trim(char))
			{

				case " ": 
					return true;
				break; 
				case "\t": 
					return true;
				break; 
				case "\r": 
					return true;
				break;
				case "\n": 
					return true;
				break; 
				case "\f": 
					return true;
				break;
				default: 
					return false;
			}
		}
		
		
		public static function trim(p_string:String):String {
			if (p_string == null) { return ''; }
			return p_string.replace(/^\s+|\s+$/g, '');
		}


		public static function trimLeft(p_string:String):String {
			if (p_string == null) { return ''; }
			return p_string.replace(/^\s+/, '');
		}


		public static function trimRight(p_string:String):String {
			if (p_string == null) { return ''; }
			return p_string.replace(/\s+$/, '');
		}
	
		
		/**
		 * 翻转字符串
		 * @param	p_string
		 * @return
		 */
		public static function reverse(p_string:String):String {
			if (p_string == null) { return ''; }
			return p_string.split('').reverse().join('');
		}
	}

}